package com.gavin.lingxi.base;


import android.app.Activity;
import android.content.Intent;

import androidx.fragment.app.Fragment;

import com.puppy.bingo.tools.ThreadUtils;


public class AppBaseFragment extends Fragment {

    static final String TAG = AppBaseFragment.class.getSimpleName();

    public final boolean isAlive() {
        Activity activity = getActivity();
        return activity != null && !activity.isFinishing() && !isRemoving() && !isDetached() && isAdded();
    }

    public boolean onBackPressed() {
        if (!isAlive()) {
            return false;
        }
        finish();
        return true;
    }

    public void finish() {
        getActivity().finish();
    }


    public final void post(Runnable r) {
        ThreadUtils.post(r);
    }

    public final void postDelayed(Runnable r, long delayMillis) {
        ThreadUtils.postDelayed(r, delayMillis);
    }

    protected void onNewIntent(Intent intent){
    }


}
